/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import core.AEntityContentProvider;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ivan
 */
@Entity
@Table(name = "TEAM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Team.findAll", query = "SELECT t FROM Team t"),
    @NamedQuery(name = "Team.findByTeamId", query = "SELECT t FROM Team t WHERE t.teamId = :teamId"),
    @NamedQuery(name = "Team.findByName", query = "SELECT t FROM Team t WHERE t.name = :name"),
    @NamedQuery(name = "Team.findByCountPlayers", query = "SELECT t FROM Team t WHERE t.countPlayers = :countPlayers")})
public class Team extends AEntityContentProvider<Team> implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(generator="CommonSeq", strategy= GenerationType.SEQUENCE)
    @Column(name = "TEAM_ID")
    private BigDecimal teamId;
    @Size(max = 20)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Column(name = "COUNT_PLAYERS")
    private BigInteger countPlayers;
    @OneToMany(mappedBy = "winnerTeamId")
    private Set<Tournament> tournamentSet;
    @OneToMany(mappedBy = "winnerTeamId")
    private Set<League> leagueSet;
    @OneToMany(mappedBy = "teamId")
    private Set<GameContract> gameContractSet;
    @OneToMany(mappedBy = "teamId")
    private Set<TeamContract> teamContractSet;
    @OneToMany(mappedBy = "winnerTeamId")
    private Set<Game> gameSet;
    @JoinColumn(name = "OWNER", referencedColumnName = "SYS_USER_ID")
    @ManyToOne(optional = false)
    private SysUser owner;
    @JoinColumn(name = "RATING_ID", referencedColumnName = "RATING_ID")
    @ManyToOne
    private Rating ratingId;
    @JoinColumn(name = "DISCIPLINE_ID", referencedColumnName = "DISCIPLINE_ID")
    @ManyToOne
    private Discipline disciplineId;

    public Team() {
    }

    public Team(BigDecimal teamId) {
        super(Team.class);
        this.teamId = teamId;
    }

    public Team(BigDecimal teamId, BigInteger countPlayers) {
        super(Team.class);
        this.teamId = teamId;
        this.countPlayers = countPlayers;
    }

    public BigDecimal getTeamId() {
        return teamId;
    }

    public void setTeamId(BigDecimal teamId) {
        this.teamId = teamId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigInteger getCountPlayers() {
        return countPlayers;
    }

    public void setCountPlayers(BigInteger countPlayers) {
        this.countPlayers = countPlayers;
    }

    @XmlTransient
    public Set<Tournament> getTournamentSet() {
        return tournamentSet;
    }

    public void setTournamentSet(Set<Tournament> tournamentSet) {
        this.tournamentSet = tournamentSet;
    }

    @XmlTransient
    public Set<League> getLeagueSet() {
        return leagueSet;
    }

    public void setLeagueSet(Set<League> leagueSet) {
        this.leagueSet = leagueSet;
    }

    @XmlTransient
    public Set<GameContract> getGameContractSet() {
        return gameContractSet;
    }

    public void setGameContractSet(Set<GameContract> gameContractSet) {
        this.gameContractSet = gameContractSet;
    }

    @XmlTransient
    public Set<TeamContract> getTeamContractSet() {
        return teamContractSet;
    }

    public void setTeamContractSet(Set<TeamContract> teamContractSet) {
        this.teamContractSet = teamContractSet;
    }

    @XmlTransient
    public Set<Game> getGameSet() {
        return gameSet;
    }

    public void setGameSet(Set<Game> gameSet) {
        this.gameSet = gameSet;
    }

    public SysUser getOwner() {
        return owner;
    }

    public void setOwner(SysUser owner) {
        this.owner = owner;
    }

    public Rating getRatingId() {
        return ratingId;
    }

    public void setRatingId(Rating ratingId) {
        this.ratingId = ratingId;
    }

    public Discipline getDisciplineId() {
        return disciplineId;
    }

    public void setDisciplineId(Discipline disciplineId) {
        this.disciplineId = disciplineId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (teamId != null ? teamId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Team)) {
            return false;
        }
        Team other = (Team) object;
        if ((this.teamId == null && other.teamId != null) || (this.teamId != null && !this.teamId.equals(other.teamId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Team[ teamId=" + teamId + " ]";
    }
    
}
